<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>JOIN_Clause | YiChangKong For Blog</title><meta name="keywords" content="MySQL"><meta name="author" content="伊长空"><meta name="copyright" content="伊长空"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="description" content="​    A table reference is also known as a join expression. 表引用也被称为连接表达式。 ​    A table reference (when it refers to a partitioned table) may contain a PARTITION clause, including a list of comma-separa">
<meta property="og:type" content="article">
<meta property="og:title" content="JOIN_Clause">
<meta property="og:url" content="https://yichangkong.gitee.io/2022/04/28/JOIN-Clause/index.html">
<meta property="og:site_name" content="YiChangKong For Blog">
<meta property="og:description" content="​    A table reference is also known as a join expression. 表引用也被称为连接表达式。 ​    A table reference (when it refers to a partitioned table) may contain a PARTITION clause, including a list of comma-separa">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg">
<meta property="article:published_time" content="2022-04-28T15:42:04.000Z">
<meta property="article:modified_time" content="2022-04-28T15:44:01.137Z">
<meta property="article:author" content="伊长空">
<meta property="article:tag" content="MySQL">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://yichangkong.gitee.io/2022/04/28/JOIN-Clause/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css"><script>var GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  ClickShowText: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  justifiedGallery: {
    js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
    css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
};

var saveToLocal = {
  set: function setWithExpiry(key, value, ttl) {
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2022-04-28 23:44:01'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
   if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }
  const autoChangeMode = 'false'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
   if (asideStatus === 'hide') {
     document.documentElement.classList.add('hide-aside')
   } else {
     document.documentElement.classList.remove('hide-aside')
   }
}})()</script><meta name="generator" content="Hexo 5.2.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="https://gitee.com/yichangkong/FigureBed/raw/master/img/20200417183933.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">45</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">9</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">45</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div></div></div></div><div id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">YiChangKong For Blog</a></span><span id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div></div><span class="close" id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></span></span></nav><div id="post-info"><h1 class="post-title">JOIN_Clause</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-04-28T15:42:04.000Z" title="发表于 2022-04-28 23:42:04">2022-04-28</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-04-28T15:44:01.137Z" title="更新于 2022-04-28 23:44:01">2022-04-28</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/MySQL/">MySQL</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/MySQL/%E5%9F%BA%E7%A1%80/">基础</a></span></div><div class="meta-secondline"> <span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p>​    A table reference is also known as a join expression.</p>
<p>表引用也被称为连接表达式。</p>
<p>​    A table reference (when it refers to a partitioned table) may contain a <code>PARTITION</code> clause, including a list of comma-separated partitions, subpartitions, or both. This option follows the name of the table and precedes any alias declaration. The effect of this option is that rows are selected only from the listed partitions or subpartitions. Any partitions or subpartitions not named in the list are ignored.  </p>
<p>​    一个表的引用（当它指的是一个分区的表）可以包含一个PARTITION子句，包括一个用逗号分隔的分区、子分区或两者的列表。这个选项跟在表的名字后面，并且在任何别名声明之前。这个选项的作用是，只从列出的分区或子分区中选择行。任何没有在列表中命名的分区或子分区都会被忽略。 </p>
<p>​    The syntax of <em><code>table_factor</code></em> is extended in MySQL in comparison with standard SQL. The standard accepts only <em><code>table_reference</code></em>, not a list of them inside a pair of parentheses.</p>
<p>This is a conservative extension if each comma in a list of <em><code>table_reference</code></em> items is considered as equivalent to an inner join. For example:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> t1 <span class="keyword">LEFT</span> <span class="keyword">JOIN</span> (t2, t3, t4)</span><br><span class="line">                 <span class="keyword">ON</span> (t2.a = t1.a <span class="keyword">AND</span> t3.b = t1.b <span class="keyword">AND</span> t4.c = t1.c)</span><br></pre></td></tr></table></figure>

<p>is equivalent to:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> t1 <span class="keyword">LEFT</span> <span class="keyword">JOIN</span> (t2 <span class="keyword">CROSS</span> <span class="keyword">JOIN</span> t3 <span class="keyword">CROSS</span> <span class="keyword">JOIN</span> t4)</span><br><span class="line">                 <span class="keyword">ON</span> (t2.a = t1.a <span class="keyword">AND</span> t3.b = t1.b <span class="keyword">AND</span> t4.c = t1.c)</span><br></pre></td></tr></table></figure>

<p>In MySQL, <code>JOIN</code>, <code>CROSS JOIN</code>, and <code>INNER JOIN</code> are syntactic equivalents (they can replace each other). In standard SQL, they are not equivalent. <code>INNER JOIN</code> is used with an <code>ON</code> clause, <code>CROSS JOIN</code> is used otherwise.</p>
<p>In general, parentheses can be ignored in join expressions containing only inner join operations. MySQL also supports nested joins. See <a target="_blank" rel="noopener external nofollow noreferrer" href="https://dev.mysql.com/doc/refman/8.0/en/nested-join-optimization.html">Section 8.2.1.8, “Nested Join Optimization”</a>.</p>
<p>Index hints can be specified to affect how the MySQL optimizer makes use of indexes. For more information, see <a target="_blank" rel="noopener external nofollow noreferrer" href="https://dev.mysql.com/doc/refman/8.0/en/index-hints.html">Section 8.9.4, “Index Hints”</a>. Optimizer hints and the <code>optimizer_switch</code> system variable are other ways to influence optimizer use of indexes. See <a target="_blank" rel="noopener external nofollow noreferrer" href="https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html">Section 8.9.3, “Optimizer Hints”</a>, and <a target="_blank" rel="noopener external nofollow noreferrer" href="https://dev.mysql.com/doc/refman/8.0/en/switchable-optimizations.html">Section 8.9.2, “Switchable Optimizations”</a>.</p>
<p>The following list describes general factors to take into account when writing joins:</p>
<ul>
<li><p>A table reference can be aliased using <code>*</code>tbl_name<code>* AS *</code>alias_name<code>*</code> or <em><code>tbl_name alias_name</code></em>:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> t1.name, t2.salary</span><br><span class="line">  <span class="keyword">FROM</span> employee <span class="keyword">AS</span> t1 <span class="keyword">INNER</span> <span class="keyword">JOIN</span> info <span class="keyword">AS</span> t2 <span class="keyword">ON</span> t1.name = t2.name;</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> t1.name, t2.salary</span><br><span class="line">  <span class="keyword">FROM</span> employee t1 <span class="keyword">INNER</span> <span class="keyword">JOIN</span> info t2 <span class="keyword">ON</span> t1.name = t2.name;</span><br></pre></td></tr></table></figure>
</li>
<li><p>A <em><code>table_subquery</code></em> is also known as a derived table or subquery in the <code>FROM</code> clause. See <a target="_blank" rel="noopener external nofollow noreferrer" href="https://dev.mysql.com/doc/refman/8.0/en/derived-tables.html">Section 13.2.11.8, “Derived Tables”</a>. Such subqueries <em>must</em> include an alias to give the subquery result a table name, and may optionally include a list of table column names in parentheses. A trivial example follows:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> (<span class="keyword">SELECT</span> <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>) <span class="keyword">AS</span> t1;</span><br></pre></td></tr></table></figure>
</li>
<li><p>The maximum number of tables that can be referenced in a single join is 61. This includes a join handled by merging derived tables and views in the <code>FROM</code> clause into the outer query block (see <a target="_blank" rel="noopener external nofollow noreferrer" href="https://dev.mysql.com/doc/refman/8.0/en/derived-table-optimization.html">Section 8.2.2.4, “Optimizing Derived Tables, View References, and Common Table Expressions with Merging or Materialization”</a>).</p>
</li>
</ul>
<ul>
<li><p><code>INNER JOIN</code> and <code>,</code> (comma) are semantically equivalent in the absence of a join condition: both produce a Cartesian product between the specified tables (that is, each and every row in the first table is joined to each and every row in the second table).</p>
<p>However, the precedence of the comma operator is less than that of <code>INNER JOIN</code>, <code>CROSS JOIN</code>, <code>LEFT JOIN</code>, and so on. If you mix comma joins with the other join types when there is a join condition, an error of the form <code>Unknown column &#39;*</code>col_name<code>*&#39; in &#39;on clause&#39;</code> may occur. Information about dealing with this problem is given later in this section.</p>
</li>
<li><p>The <em><code>search_condition</code></em> used with <code>ON</code> is any conditional expression of the form that can be used in a <code>WHERE</code> clause. Generally, the <code>ON</code> clause serves for conditions that specify how to join tables, and the <code>WHERE</code> clause restricts which rows to include in the result set.</p>
</li>
<li><p>If there is no matching row for the right table in the <code>ON</code> or <code>USING</code> part in a <code>LEFT JOIN</code>, a row with all columns set to <code>NULL</code> is used for the right table. You can use this fact to find rows in a table that have no counterpart in another table:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> left_tbl.*</span><br><span class="line">  <span class="keyword">FROM</span> left_tbl <span class="keyword">LEFT</span> <span class="keyword">JOIN</span> right_tbl <span class="keyword">ON</span> left_tbl.id = right_tbl.id</span><br><span class="line">  <span class="keyword">WHERE</span> right_tbl.id <span class="keyword">IS</span> <span class="literal">NULL</span>;</span><br></pre></td></tr></table></figure>

<p>This example finds all rows in <code>left_tbl</code> with an <code>id</code> value that is not present in <code>right_tbl</code> (that is, all rows in <code>left_tbl</code> with no corresponding row in <code>right_tbl</code>). See <a target="_blank" rel="noopener external nofollow noreferrer" href="https://dev.mysql.com/doc/refman/8.0/en/outer-join-optimization.html">Section 8.2.1.9, “Outer Join Optimization”</a>.</p>
</li>
<li><p>The <code>USING(*</code>join_column_list<code>*)</code> clause names a list of columns that must exist in both tables. If tables <code>a</code> and <code>b</code> both contain columns <code>c1</code>, <code>c2</code>, and <code>c3</code>, the following join compares corresponding columns from the two tables:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a LEFT JOIN b USING (c1, c2, c3)</span><br></pre></td></tr></table></figure>
</li>
<li><p>The <code>NATURAL [LEFT] JOIN</code> of two tables is defined to be semantically equivalent to an <code>INNER JOIN</code> or a <code>LEFT JOIN</code> with a <code>USING</code> clause that names all columns that exist in both tables.</p>
</li>
<li><p><code>RIGHT JOIN</code> works analogously to <code>LEFT JOIN</code>. To keep code portable across databases, it is recommended that you use <code>LEFT JOIN</code> instead of <code>RIGHT JOIN</code>.</p>
</li>
<li><p>The <code>&#123; OJ ... &#125;</code> syntax shown in the join syntax description exists only for compatibility with ODBC. The curly braces in the syntax should be written literally; they are not metasyntax as used elsewhere in syntax descriptions.</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> left_tbl.*</span><br><span class="line">    <span class="keyword">FROM</span> &#123; OJ left_tbl <span class="keyword">LEFT</span> <span class="keyword">OUTER</span> <span class="keyword">JOIN</span> right_tbl</span><br><span class="line">           <span class="keyword">ON</span> left_tbl.id = right_tbl.id &#125;</span><br><span class="line">    <span class="keyword">WHERE</span> right_tbl.id <span class="keyword">IS</span> <span class="literal">NULL</span>;</span><br></pre></td></tr></table></figure>

<p>You can use other types of joins within <code>&#123; OJ ... &#125;</code>, such as <code>INNER JOIN</code> or <code>RIGHT OUTER JOIN</code>. This helps with compatibility with some third-party applications, but is not official ODBC syntax.</p>
</li>
<li><p><code>STRAIGHT_JOIN</code> is similar to <code>JOIN</code>, except that the left table is always read before the right table. This can be used for those (few) cases for which the join optimizer processes the tables in a suboptimal order.</p>
</li>
</ul>
<p>Some join examples:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> table1, table2;</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> table1 <span class="keyword">INNER</span> <span class="keyword">JOIN</span> table2 <span class="keyword">ON</span> table1.id = table2.id;</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> table1 <span class="keyword">LEFT</span> <span class="keyword">JOIN</span> table2 <span class="keyword">ON</span> table1.id = table2.id;</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> table1 <span class="keyword">LEFT</span> <span class="keyword">JOIN</span> table2 <span class="keyword">USING</span> (<span class="keyword">id</span>);</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> table1 <span class="keyword">LEFT</span> <span class="keyword">JOIN</span> table2 <span class="keyword">ON</span> table1.id = table2.id</span><br><span class="line">  <span class="keyword">LEFT</span> <span class="keyword">JOIN</span> table3 <span class="keyword">ON</span> table2.id = table3.id;</span><br></pre></td></tr></table></figure>

<p>Natural joins and joins with <code>USING</code>, including outer join variants, are processed according to the SQL:2003 standard:</p>
<ul>
<li><p>Redundant columns of a <code>NATURAL</code> join do not appear. Consider this set of statements:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t1 (i <span class="built_in">INT</span>, j <span class="built_in">INT</span>);</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t2 (k <span class="built_in">INT</span>, j <span class="built_in">INT</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> t1 <span class="keyword">VALUES</span>(<span class="number">1</span>, <span class="number">1</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> t2 <span class="keyword">VALUES</span>(<span class="number">1</span>, <span class="number">1</span>);</span><br><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> t1 <span class="keyword">NATURAL</span> <span class="keyword">JOIN</span> t2;</span><br><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> t1 <span class="keyword">JOIN</span> t2 <span class="keyword">USING</span> (j);</span><br></pre></td></tr></table></figure>

<p>In the first <a target="_blank" rel="noopener external nofollow noreferrer" href="https://dev.mysql.com/doc/refman/8.0/en/select.html"><code>SELECT</code></a> statement, column <code>j</code> appears in both tables and thus becomes a join column, so, according to standard SQL, it should appear only once in the output, not twice. Similarly, in the second SELECT statement, column <code>j</code> is named in the <code>USING</code> clause and should appear only once in the output, not twice.</p>
<p>Thus, the statements produce this output:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">+------+------+------+</span><br><span class="line">| j    | i    | k    |</span><br><span class="line">+------+------+------+</span><br><span class="line">|    1 |    1 |    1 |</span><br><span class="line">+------+------+------+</span><br><span class="line">+------+------+------+</span><br><span class="line">| j    | i    | k    |</span><br><span class="line">+------+------+------+</span><br><span class="line">|    1 |    1 |    1 |</span><br><span class="line">+------+------+------+</span><br></pre></td></tr></table></figure>

<p>Redundant column elimination and column ordering occurs according to standard SQL, producing this display order:</p>
<ul>
<li>First, coalesced common columns of the two joined tables, in the order in which they occur in the first table</li>
<li>Second, columns unique to the first table, in order in which they occur in that table</li>
<li>Third, columns unique to the second table, in order in which they occur in that table</li>
</ul>
<p>The single result column that replaces two common columns is defined using the coalesce operation. That is, for two <code>t1.a</code> and <code>t2.a</code> the resulting single join column <code>a</code> is defined as <code>a = COALESCE(t1.a, t2.a)</code>, where:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COALESCE(x, y) = (CASE WHEN x IS NOT NULL THEN x ELSE y <span class="keyword">END</span>)</span><br></pre></td></tr></table></figure>

<p>If the join operation is any other join, the result columns of the join consist of the concatenation of all columns of the joined tables.</p>
<p>A consequence of the definition of coalesced columns is that, for outer joins, the coalesced column contains the value of the non-<code>NULL</code> column if one of the two columns is always <code>NULL</code>. If neither or both columns are <code>NULL</code>, both common columns have the same value, so it doesn’t matter which one is chosen as the value of the coalesced column. A simple way to interpret this is to consider that a coalesced column of an outer join is represented by the common column of the inner table of a <code>JOIN</code>. Suppose that the tables <code>t1(a, b)</code> and <code>t2(a, c)</code> have the following contents:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">t1    t2</span><br><span class="line">----  ----</span><br><span class="line">1 x   2 z</span><br><span class="line">2 y   3 w</span><br></pre></td></tr></table></figure>

<p>Then, for this join, column <code>a</code> contains the values of <code>t1.a</code>:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; SELECT * FROM t1 NATURAL LEFT JOIN t2;</span><br><span class="line">+<span class="comment">------+------+------+</span></span><br><span class="line">| a    | b    | c    |</span><br><span class="line">+<span class="comment">------+------+------+</span></span><br><span class="line">|    1 | x    | NULL |</span><br><span class="line">|    2 | y    | z    |</span><br><span class="line">+<span class="comment">------+------+------+</span></span><br></pre></td></tr></table></figure>

<p>By contrast, for this join, column <code>a</code> contains the values of <code>t2.a</code>.</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; SELECT * FROM t1 NATURAL RIGHT JOIN t2;</span><br><span class="line">+<span class="comment">------+------+------+</span></span><br><span class="line">| a    | c    | b    |</span><br><span class="line">+<span class="comment">------+------+------+</span></span><br><span class="line">|    2 | z    | y    |</span><br><span class="line">|    3 | w    | NULL |</span><br><span class="line">+<span class="comment">------+------+------+</span></span><br></pre></td></tr></table></figure>

<p>Compare those results to the otherwise equivalent queries with <code>JOIN ... ON</code>:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; SELECT * FROM t1 LEFT JOIN t2 ON (t1.a = t2.a);</span><br><span class="line">+<span class="comment">------+------+------+------+</span></span><br><span class="line">| a    | b    | a    | c    |</span><br><span class="line">+<span class="comment">------+------+------+------+</span></span><br><span class="line">|    1 | x    | NULL | NULL |</span><br><span class="line">|    2 | y    |    2 | z    |</span><br><span class="line">+<span class="comment">------+------+------+------+</span></span><br></pre></td></tr></table></figure>

<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a = t2.a);</span><br><span class="line">+<span class="comment">------+------+------+------+</span></span><br><span class="line">| a    | b    | a    | c    |</span><br><span class="line">+<span class="comment">------+------+------+------+</span></span><br><span class="line">|    2 | y    |    2 | z    |</span><br><span class="line">| NULL | NULL |    3 | w    |</span><br><span class="line">+<span class="comment">------+------+------+------+</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>A <code>USING</code> clause can be rewritten as an <code>ON</code> clause that compares corresponding columns. However, although <code>USING</code> and <code>ON</code> are similar, they are not quite the same. Consider the following two queries:</p>
</li>
</ul>
  <figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">a LEFT JOIN b USING (c1, c2, c3)</span><br><span class="line">a LEFT JOIN b ON a.c1 = b.c1 AND a.c2 = b.c2 AND a.c3 = b.c3</span><br></pre></td></tr></table></figure>

<p>  With respect to determining which rows satisfy the join condition, both joins are semantically identical.</p>
<p>  With respect to determining which columns to display for <code>SELECT *</code> expansion, the two joins are not semantically identical. The <code>USING</code> join selects the coalesced value of corresponding columns, whereas the <code>ON</code> join selects all columns from all tables. For the <code>USING</code> join, <code>SELECT *</code> selects these values:</p>
  <figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COALESCE(a.c1, b.c1), COALESCE(a.c2, b.c2), COALESCE(a.c3, b.c3)</span><br></pre></td></tr></table></figure>

<p>  For the <code>ON</code> join, <code>SELECT *</code> selects these values:</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a.c1, a.c2, a.c3, b.c1, b.c2, b.c3</span><br></pre></td></tr></table></figure>

<p>  With an inner join, <a target="_blank" rel="noopener external nofollow noreferrer" href="https://dev.mysql.com/doc/refman/8.0/en/comparison-operators.html#function_coalesce"><code>COALESCE(a.c1, b.c1)</code></a> is the same as either <code>a.c1</code> or <code>b.c1</code> because both columns have the same value. With an outer join (such as <code>LEFT JOIN</code>), one of the two columns can be <code>NULL</code>. That column is omitted from the result.</p>
<ul>
<li><p>An <code>ON</code> clause can refer only to its operands.</p>
<p>Example:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t1 (i1 <span class="built_in">INT</span>);</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t2 (i2 <span class="built_in">INT</span>);</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t3 (i3 <span class="built_in">INT</span>);</span><br><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> t1 <span class="keyword">JOIN</span> t2 <span class="keyword">ON</span> (i1 = i3) <span class="keyword">JOIN</span> t3;</span><br></pre></td></tr></table></figure>

<p>The statement fails with an <code>Unknown column &#39;i3&#39; in &#39;on clause&#39;</code> error because <code>i3</code> is a column in <code>t3</code>, which is not an operand of the <code>ON</code> clause. To enable the join to be processed, rewrite the statement as follows:</p>
</li>
</ul>
  <figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> t1 <span class="keyword">JOIN</span> t2 <span class="keyword">JOIN</span> t3 <span class="keyword">ON</span> (i1 = i3);</span><br></pre></td></tr></table></figure>

<ul>
<li><p><code>JOIN</code> has higher precedence than the comma operator (<code>,</code>), so the join expression <code>t1, t2 JOIN t3</code> is interpreted as <code>(t1, (t2 JOIN t3))</code>, not as <code>((t1, t2) JOIN t3)</code>. This affects statements that use an <code>ON</code> clause because that clause can refer only to columns in the operands of the join, and the precedence affects interpretation of what those operands are.</p>
<p>Example:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t1 (i1 <span class="built_in">INT</span>, j1 <span class="built_in">INT</span>);</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t2 (i2 <span class="built_in">INT</span>, j2 <span class="built_in">INT</span>);</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> t3 (i3 <span class="built_in">INT</span>, j3 <span class="built_in">INT</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> t1 <span class="keyword">VALUES</span>(<span class="number">1</span>, <span class="number">1</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> t2 <span class="keyword">VALUES</span>(<span class="number">1</span>, <span class="number">1</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> t3 <span class="keyword">VALUES</span>(<span class="number">1</span>, <span class="number">1</span>);</span><br><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> t1, t2 <span class="keyword">JOIN</span> t3 <span class="keyword">ON</span> (t1.i1 = t3.i3);</span><br></pre></td></tr></table></figure>

<p>The <code>JOIN</code> takes precedence over the comma operator, so the operands for the <code>ON</code> clause are <code>t2</code> and <code>t3</code>. Because <code>t1.i1</code> is not a column in either of the operands, the result is an <code>Unknown column &#39;t1.i1&#39; in &#39;on clause&#39;</code> error.</p>
</li>
</ul>
<p>  To enable the join to be processed, use either of these strategies:</p>
<ul>
<li><p>Group the first two tables explicitly with parentheses so that the operands for the <code>ON</code> clause are <code>(t1, t2)</code> and <code>t3</code>:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> (t1, t2) <span class="keyword">JOIN</span> t3 <span class="keyword">ON</span> (t1.i1 = t3.i3);</span><br></pre></td></tr></table></figure>
</li>
<li><p>Avoid the use of the comma operator and use <code>JOIN</code> instead:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> * <span class="keyword">FROM</span> t1 <span class="keyword">JOIN</span> t2 <span class="keyword">JOIN</span> t3 <span class="keyword">ON</span> (t1.i1 = t3.i3);</span><br></pre></td></tr></table></figure>

<p>The same precedence interpretation also applies to statements that mix the comma operator with <code>INNER JOIN</code>, <code>CROSS JOIN</code>, <code>LEFT JOIN</code>, and <code>RIGHT JOIN</code>, all of which have higher precedence than the comma operator.</p>
</li>
</ul>
<ul>
<li>A MySQL extension compared to the SQL:2003 standard is that MySQL permits you to qualify the common (coalesced) columns of <code>NATURAL</code> or <code>USING</code> joins, whereas the standard disallows that.</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined" rel="external nofollow noreferrer">伊长空</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://yichangkong.gitee.io/2022/04/28/JOIN-Clause/">https://yichangkong.gitee.io/2022/04/28/JOIN-Clause/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow noreferrer" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://yichangkong.gitee.io" target="_blank">YiChangKong For Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/MySQL/">MySQL</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="next-post pull-full"><a href="/2022/03/24/Vim%E9%94%AE%E4%BD%8D%E5%9B%BE/"><img class="next-cover" src="https://gitee.com/yichangkong/FigureBed/raw/master/img/vi-vim-cheat-sheet-sch.jpg" onerror="onerror=null;src='/img/404.jpg'"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Vim键位图</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside_content" id="aside_content"><div class="card-widget card-info"><div class="card-content"><div class="card-info-avatar is-center"><img class="avatar-img" src="https://gitee.com/yichangkong/FigureBed/raw/master/img/20200417183933.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">伊长空</div><div class="author-info__description">空气越稀薄 、风景越广阔</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">45</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">9</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">45</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/CodeSnakes"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/yichangkong" rel="external nofollow noreferrer" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:changkongyi@gmail.com" rel="external nofollow noreferrer" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div></div><div class="card-widget card-announcement"><div class="card-content"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">繁华落尽一场空 ：风往尘香花已尽 <br> 		<div class="is-center"> 欢迎访问 <br> <a class="bookmark button--primary" id="bookmark-it" href="https://jq.qq.com/?_wv=1027&amp;k=rCby8DjL" rel="external nofollow noreferrer" title="" target="_self"><i aria-hidden="true"> </i><span>Join QQ Group 👍</span></a></div></div></div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="card-content"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2022/04/28/JOIN-Clause/" title="JOIN_Clause"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JOIN_Clause"/></a><div class="content"><a class="title" href="/2022/04/28/JOIN-Clause/" title="JOIN_Clause">JOIN_Clause</a><time datetime="2022-04-28T15:42:04.000Z" title="发表于 2022-04-28 23:42:04">2022-04-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/03/24/Vim%E9%94%AE%E4%BD%8D%E5%9B%BE/" title="Vim键位图"><img src="https://gitee.com/yichangkong/FigureBed/raw/master/img/vi-vim-cheat-sheet-sch.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vim键位图"/></a><div class="content"><a class="title" href="/2022/03/24/Vim%E9%94%AE%E4%BD%8D%E5%9B%BE/" title="Vim键位图">Vim键位图</a><time datetime="2022-03-24T03:32:15.000Z" title="发表于 2022-03-24 11:32:15">2022-03-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/12/requirejs%20Overview/" title="RequireJs Overview"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="RequireJs Overview"/></a><div class="content"><a class="title" href="/2021/01/12/requirejs%20Overview/" title="RequireJs Overview">RequireJs Overview</a><time datetime="2021-01-12T02:43:34.000Z" title="发表于 2021-01-12 10:43:34">2021-01-12</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2020/12/12/SSM%E6%9E%B6%E6%9E%84%E4%B8%8B%E7%9A%84Cors%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98/" title="SSM架构下的Cors跨域问题"><img src="https://gitee.com/yichangkong/FigureBed/raw/master/img/20201213132701.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="SSM架构下的Cors跨域问题"/></a><div class="content"><a class="title" href="/2020/12/12/SSM%E6%9E%B6%E6%9E%84%E4%B8%8B%E7%9A%84Cors%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98/" title="SSM架构下的Cors跨域问题">SSM架构下的Cors跨域问题</a><time datetime="2020-12-12T13:13:28.000Z" title="发表于 2020-12-12 21:13:28">2020-12-12</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2020/11/25/DataTable/" title="DataTable"><img src="https://gitee.com/yichangkong/FigureBed/raw/master/img/20201125100521.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="DataTable"/></a><div class="content"><a class="title" href="/2020/11/25/DataTable/" title="DataTable">DataTable</a><time datetime="2020-11-25T01:45:41.000Z" title="发表于 2020-11-25 09:45:41">2020-11-25</time></div></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By 伊长空</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener external nofollow noreferrer" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><div class="js-pjax"><script>function loadValine () {
  function initValine () {
    let initData = {
      el: '#vcomment',
      appId: 'xuXblFdHlR0fcnQsdkLwkqvG-gzGzoHsz',
      appKey: 'ac3XS1leXcL95PWUhYV6gx0E',
      placeholder: 'Please leave your footprints',
      avatar: 'retro',
      meta: 'nick,mail'.split(','),
      pageSize: '10',
      lang: 'en',
      recordIP: false,
      serverURLs: '',
      emojiCDN: 'https://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/',
      emojiMaps: {"tv_doge":"6ea59c827c414b4a2955fe79e0f6fd3dcd515e24.png","tv_亲亲":"a8111ad55953ef5e3be3327ef94eb4a39d535d06.png","tv_偷笑":"bb690d4107620f1c15cff29509db529a73aee261.png","tv_再见":"180129b8ea851044ce71caf55cc8ce44bd4a4fc8.png","tv_冷漠":"b9cbc755c2b3ee43be07ca13de84e5b699a3f101.png","tv_发怒":"34ba3cd204d5b05fec70ce08fa9fa0dd612409ff.png","tv_发财":"34db290afd2963723c6eb3c4560667db7253a21a.png","tv_可爱":"9e55fd9b500ac4b96613539f1ce2f9499e314ed9.png","tv_吐血":"09dd16a7aa59b77baa1155d47484409624470c77.png","tv_呆":"fe1179ebaa191569b0d31cecafe7a2cd1c951c9d.png","tv_呕吐":"9f996894a39e282ccf5e66856af49483f81870f3.png","tv_困":"241ee304e44c0af029adceb294399391e4737ef2.png","tv_坏笑":"1f0b87f731a671079842116e0991c91c2c88645a.png","tv_大佬":"093c1e2c490161aca397afc45573c877cdead616.png","tv_大哭":"23269aeb35f99daee28dda129676f6e9ea87934f.png","tv_委屈":"d04dba7b5465779e9755d2ab6f0a897b9b33bb77.png","tv_害羞":"a37683fb5642fa3ddfc7f4e5525fd13e42a2bdb1.png","tv_尴尬":"7cfa62dafc59798a3d3fb262d421eeeff166cfa4.png","tv_微笑":"70dc5c7b56f93eb61bddba11e28fb1d18fddcd4c.png","tv_思考":"90cf159733e558137ed20aa04d09964436f618a1.png","tv_惊吓":"0d15c7e2ee58e935adc6a7193ee042388adc22af.png"},
      enableQQ: false,
      path: window.location.pathname,
    }

    if (true) { 
      initData.requiredFields= ('nick'.split(','))
    }
    
    if (false) {
      const otherData = false
      initData = Object.assign({}, initData, otherData)
    }
    
    const valine = new Valine(initData)
  }

  if (typeof Valine === 'function') initValine() 
  else $.getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js', initValine)
}

if ('Valine' === 'Valine' || !false) {
  if (false) btf.loadComment(document.querySelector('#vcomment'),loadValine)
  else setTimeout(() => loadValine(), 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src="https://cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script></div></body></html>